package com.jhy.ws.constants;




import java.util.Arrays;


public interface WebSocketConstant {

    String USER = "USER";

    String H5_USER = "H5_USER";

    String APP_USER = "APP_USER";

    // 用户标识key
    String TOKEN = "token";

    // loginId
    String LOGINID = "loginId";

    // Ws上线发送上线提醒队列
    String ONLINE_STATUS_QUEUE = "ONLINE_STATUS_QUEUE";


    enum MessageType implements WebSocketConstant {
        TEXT,
        FILE,
        ;

        public static MessageType getMessageType(String type) {
            return Arrays.stream(MessageType.values()).filter(m -> m.name().equals(type)).findFirst().orElseThrow(
                    () -> new RuntimeException("消息类型不存在"));
        }

    }

    enum TargetType implements WebSocketConstant {
        USER,
        APP_USER,
        GROUP,
        ;

        public static TargetType getMessageType(String type) {
            return Arrays.stream(TargetType.values()).filter(m -> m.name().equals(type)).findFirst().orElseThrow(
                    () -> new RuntimeException("目标类型不存在"));
        }
    }
}
